<!-- 模块说明 -->

<script setup lang='ts'>
import { ref, onMounted } from 'vue';
import axios from 'axios';
const orderlist = ref([])
//获取订单列表
const getorderlist = async () => {
    if (localStorage.getItem('pinia-customer')) {
        let res = await axios({
            url: 'http://182.92.162.156:8083/order/list',
            method: 'get'
        })
        console.log(res.data.data, 'shuju');
        orderlist.value = res.data.data.filter((item: any) => item.userid == JSON.parse(localStorage.getItem('pinia-customer') + '').userid)
    }
};


//删除订单
const del = async (id: any) => {
    let res = await axios({
        url: 'http://182.92.162.156:8083/order/delete',
        method: 'post',
        data: {
            orderid: id
        }
    })
    console.log(res, '删除');
    getorderlist()
}

onMounted(() => {
    getorderlist()
})
</script>

<template>
    <div class="box">
        <div>
            <el-table :data="orderlist" empty-text="您还没有订单" height="600" style="width: 100%">
                <el-table-column min-width="40" prop="time" label="下单时间" />
                <el-table-column min-width="40" prop="ordernumber" label="订单编号" />
                <el-table-column min-width="40" prop="untitled" label="订单详情" />
                <el-table-column min-width="40" prop="totalfee" label="付款（元）" />
                <el-table-column min-width="40" prop="orderinfo" label="备注" />
                <el-table-column min-width="40" label="操作">
                    <template #default="scope">
                        <div>
                            <el-button size="small" type="danger" @click="del(scope.row.orderid)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.myorder {
    font-weight: bold;
    font-size: 18px;
    padding-left: 10px;
}
</style>
